package day32;

import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;

// 构造方法引用
// 类名::new
// 具体引用哪个构造方法
// 就看lambda表达折参数列表与哪个构造方法的参数列表一致
public class Demo04 {
	public static void main(String[] args) {
		Supplier<Emp> sup = () -> new Emp();
		Supplier<Emp> sup2 = Emp::new;
		Emp e = sup2.get();

		Function<String, Emp> fun = name -> new Emp(name);
		Function<String, Emp> fun2 = Emp::new;
		Emp e2 = fun2.apply("alice");

		BiFunction<String, Integer, Emp> bifun = (name, age) -> new Emp(name, age);
		BiFunction<String, Integer, Emp> sifun2 = Emp::new;

		// 数组的构造方法引用: 类型[]::new
		Function<Integer, String[]> fun3 = n -> new String[n];
		Function<Integer, String[]> fun4 = String[]::new;
		String[] arr = fun4.apply(10);
	}
}
